Install Vagga
Vagga is a userspace container built using rust. To install, run:
Setup tauri application
Quickly setup tauri application using the create-tauri-app
crate.
cargo install create-tauri-app
Add vagga.yaml
file to the root of the application base directory. Additional script commands may be added to an external shell file to keep yaml file neat and easily readable. For this also create a vagga.sh
file at the base url and make it executable.
Other files that shall be required during compilation are app.wxs
and app.manifest
files. The app.wxs
file defines the wix configuration settings to be used while creating a .msi
executable. app.manifest
is included to describe and identify assemblies that prevent the compiled executable file from running into errors.
You will also need to create a License.rtf
file.
Resulting directory structure should look like
├── tauri-app
├── src
├── src-tauri
│ ├── src
│ ├── app.manifest
│ ├── build.rs
│ ├── cargo.toml
│ ├── tauri.conf.json
├── .gitignore
├── app.wxs
├── License.rtf
├── README.md
├── vagga.sh
├── vagga.yaml
File Modifications
cargo.toml
Add:
[]
= "1.3.1"
build.rs
use ;
app.manifest
Rust Manifest Example
True/PM
PerMonitorV2
app.wxs
vagga.yaml
most of the cross compilation variables were sourced from: xwin blog post
containers:
tauri:
auto-clean: true
setup:
-
- HOME: /work/.vagga/home
- |
mkdir -p .vagga/home
mkdir -p .vagga/run/user/root
- |
# install required packages
apt install -y software-properties-common gpg gpg-agent gnupg-agent
add-apt-repository -y ppa:apt-fast/stable
apt-add-repository -y universe
apt-add-repository -y multiverse
add-apt-repository -y ppa:vala-team/next
apt update
# install base packages and dependencies
DEBIAN_FRONTEND=noninteractive apt install -y apt-fast axel aria2
apt-fast install -y curl ca-certificates build-essential libssl-dev pkg-config cmake make tar meson ninja-build git valac bison libgsf-1-dev libglib2.0-dev libgio-qt-dev libgcab-dev libgirepository1.0-dev
curl --fail https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor > $KEYRINGS/llvm.gpg;
echo "deb [signed-by=$KEYRINGS/llvm.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" > /etc/apt/sources.list.d/llvm.list;
apt update
# install llvm
apt-fast install -y llvm-15 lld-15 clang-15 libobjc-11-dev
# ensure that clang/clang++ are callable directly
ln -s clang-15 /usr/bin/clang && ln -s clang /usr/bin/clang++ && ln -s lld-15 /usr/bin/ld.lld
# We also need to setup symlinks ourselves for the MSVC shims because they aren't in the debian packages
ln -s clang-15 /usr/bin/clang-cl && ln -s llvm-ar-15 /usr/bin/llvm-lib && ln -s lld-link-15 /usr/bin/lld-link
# Use clang instead of gcc when compiling binaries targeting the host (eg proc macros, build files)
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
# msitools build
cd ~/
rm -rf msitools
git clone --recurse-submodules -j8 https://gitlab.gnome.org/GNOME/msitools.git
cd msitools
meson build
ninja -C build
meson install -C build
# delete resolv.conf file; causes build time dns errors
rm -rf /etc/resolv.conf
environ:
HOME: /work/.vagga/home
USER: root
XDG_RUNTIME_DIR: /work/.vagga/run/user/root
XDG_CACHE_HOME: /work/.vagga/home/.cache
PATH: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/work/.vagga/home/.local/bin:/work/.vagga/home/.cargo/bin
CARGO_HOME: /work/.vagga/home/.cargo
LD_LIBRARY_PATH: /usr/local/lib
CC_x86_64_pc_windows_msvc: "clang-cl"
CXX_x86_64_pc_windows_msvc: "clang-cl"
AR_x86_64_pc_windows_msvc: "llvm-lib"
CL_FLAGS: "-Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/xwin/crt/include /imsvc/xwin/sdk/include/ucrt /imsvc/xwin/sdk/include/um /imsvc/xwin/sdk/include/shared"
CFLAGS_x86_64_pc_windows_msvc: "-Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/xwin/crt/include /imsvc/xwin/sdk/include/ucrt /imsvc/xwin/sdk/include/um /imsvc/xwin/sdk/include/shared"
CXXFLAGS_x86_64_pc_windows_msvc: "-Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/xwin/crt/include /imsvc/xwin/sdk/include/ucrt /imsvc/xwin/sdk/include/um /imsvc/xwin/sdk/include/shared"
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: "lld-link"
RUSTFLAGS: "-Lnative=/work/.vagga/home/xwin/crt/lib/x86_64 -Lnative=/work/.vagga/home/xwin/sdk/lib/um/x86_64 -Lnative=/work/.vagga/home/xwin/sdk/lib/ucrt/x86_64"
volumes:
/tmp:
size: 1G
tools:
auto-clean: true
setup:
- tauri
- PATH: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/work/.vagga/home/.local/bin:/work/.vagga/home/.cargo/bin
- CARGO_HOME: /work/.vagga/home/.cargo
- LD_LIBRARY_PATH: /usr/local/lib
- |
ldconfig
# install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# install cargo build packages
cargo install xwin --git https://github.com/Jake-Shadle/xwin.git --rev 11e18b581aad2158b84f2c689d6c294edba5ec29
rm -rf /work/.vagga/home/xwin
xwin --accept-license splat --output /work/.vagga/home/xwin
rm -rf .xwin-cache /usr/local/cargo/bin/xwin
environ: *envs
volumes: *vols
commands:
init:
run: vagga _capsule build tauri
description: initialize container
tools:
run: vagga _capsule build tools
description: install and setup tools needed for cross compilation
dist:
container: tools
run: |
# set rustup to stable version
rustup default stable
# add target arch
rustup target add x86_64-pc-windows-msvc
# run build script
/work/vagga.sh
description: package and distribute tauri packages
sh:
container: tauri
run: bash
description: execute bash
vagga.sh
#!/bin/bash
BASEDIR=""
# compile windows executable .exe release file
# Copy files required to build .msi executable
# rename .exe file to name specified in app.wxs
# build .msi executable and move to dist folder using wixl msitool
Final
Finally run vagga dist
in the root application folder from terminal